package com.zyb.warehouse.mapper;

import com.zyb.warehouse.entity.RoleAuth;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Description:角色权限关系表持久层
 */
@Mapper
public interface RoleAuthMapper {

    /**
     * 根据角色ID删除角色权限关系
     *
     * @param roleId
     * @return
     */
    @Delete("delete from role_auth where role_id=#{roleId}")
    Integer deleteRoleAuth(Integer roleId);

    /**
     * 根据角色ID查询已经分配给角色的权限
     *
     * @param roleId
     * @return
     */
    @Select("select auth_id from role_auth where role_id=#{roleId}")
    List<Integer> selectAllAuthByRoleId(Integer roleId);

    /**
     * 给角色分配权限（添加角色权限）
     *
     * @param roleAuth
     * @return
     */
    @Insert("insert into role_auth values (null,#{roleId},#{authId})")
    Integer insertRoleAuth(RoleAuth roleAuth);
}
